package com.oracle.controller;

import com.oracle.common.PageResult;
import com.oracle.common.R;
import com.oracle.pojo.Wx;
import com.oracle.service.WxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wx")
public class WxController {
    @Autowired
    private WxService wxService;

    @GetMapping("find")
    public List<Wx> findList()
    {
        List<Wx> list = wxService.findList();
        return list;
    }

    @PostMapping("find2")
    public R<Wx> findPages2(@RequestBody Wx wx, Integer pageNo, Integer pageSize)
    {
        if(ObjectUtils.isEmpty(pageNo)){
            pageNo = 1;
        }

        if(ObjectUtils.isEmpty(pageSize)){
            pageSize = 10;
        }

        PageResult pages = wxService.findPages(pageNo, pageSize,wx);
        return R.success(pages);
    }
}
